package com.colorlight.cloud.complete.entity.po;

import com.colorlight.cloud.complete.entity.enumerate.Weekday;
import com.colorlight.cloud.gateway.api.message.constraint.basics.object.Trans;
import com.colorlight.iot.proto.complete.entity.CompleteEntity;
import lombok.*;

import java.time.DateTimeException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class FunctionTime implements Trans<FunctionTime, CompleteEntity.FunctionTime> {

    /**
     * 时间
     */
    private Time time;

    /**
     * 星期
     */
    private List<Weekday> weekday;
    
    
    
    @Override
    public CompleteEntity.FunctionTime toProto() {
   
        CompleteEntity.FunctionTime.Builder builder = CompleteEntity.FunctionTime.newBuilder();
        builder.setTime(this.time.toProto());
        builder.setWeekday(Weekday.getWeekday(weekday));
        return builder.build();
    }
    
    @Override
    public FunctionTime formProto(@NonNull CompleteEntity.FunctionTime functionTime) {
        this.setTime(new Time().formProto(functionTime.getTime()));
        this.setWeekday(Weekday.getWeekday(functionTime.getWeekday()));
        return this;
    }
}

